home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Communications / pcomm / Source / s_term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  3.1 KB  |  109 lines

  1. /*
  2.  * Display the terminal setup, query for changes.  A return code of 1
  3.  * means something was changed, 2 means we have to kill and restart
  4.  * the input routine.
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <curses.h>
  9. #include "config.h"
  10. #include "dial_dir.h"
  11. #include "misc.h"
  12. #include "param.h"
  13. #include "status.h"
  14.  
  15. int
  16. term_setup()
  17. {
  18.     WINDOW *t_win, *newwin();
  19.     int i, num, ret_code;
  20.     char *ans, *str_rep(), *str_prompt(), *menu_prompt();
  21.     void input_off(), line_set();
  22.     static char *v_crio[3] = {"CR", "CR/LF", NULL};
  23.     static char *v_duplex[3] = {"FULL", "HALF", NULL};
  24.     static char *v_flow[3] = {"NONE", "XON/XOFF", NULL};
  25.  
  26.     t_win = newwin(23, 80, 0, 0);
  27.  
  28.     horizontal(t_win, 0, 0, 32);
  29.     mvwattrstr(t_win, 0, 33, A_BOLD, "Terminal Setup");
  30.     horizontal(t_win, 0, 48, 32);
  31.     mvwprintw(t_win, 4, 22, "1) Hot key (decimal) ...... %d", param->hot);
  32.     mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  33.     mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  34.     mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
  35.     mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  36.     mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  37.     horizontal(t_win, 19, 0, 80);
  38.     mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  39.     mvwaddstr(t_win, 20, 58, "Press <ESC> to return");
  40.     wmove(t_win, 20, 12);
  41.     touchwin(t_win);
  42.     wrefresh(t_win);
  43.                     /* get the option number */
  44.     ret_code = 0;
  45.     while ((i = get_num(t_win, 1)) != -1) {
  46.         switch (i) {
  47.             case 1:
  48.                 if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  49.                     param->hot = num;
  50.                     ret_code = 1;
  51.                 }
  52.                 break;
  53.             case 2:
  54.                 if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
  55.                     param->ascii_hot = str_rep(param->ascii_hot, ans);
  56.                     ret_code = 1;
  57.                 }
  58.                 break;
  59.             case 3:
  60.                 if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL) {
  61.                     param->d_duplex = str_rep(param->d_duplex, ans);
  62.                     if (dir->d_cur != -1)
  63.                         dir->duplex[dir->d_cur] = *param->d_duplex;
  64.                     ret_code = 1;
  65.                 }
  66.                 break;
  67.             case 4:
  68.                 if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL) {
  69.                     param->flow = str_rep(param->flow, ans);
  70.                     line_set();
  71.                     ret_code = 1;
  72.                 }
  73.                 break;
  74.             case 5:
  75.                 if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL) {
  76.  
  77.                     /*
  78.                      * the "add lf to cr" function is
  79.                      * performed by the input routine
  80.                      */
  81.                     param->cr_in = str_rep(param->cr_in, ans);
  82.                     status->add_lf = !strcmp(ans, "CR/LF");
  83. #ifdef SHAREDMEM
  84.                     ret_code = 1;
  85. #else /* SHAREDMEM */
  86.                     input_off();
  87.                     ret_code = 2;
  88. #endif /* SHAREDMEM */
  89.                 }
  90.                 break;
  91.             case 6:
  92.                 if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL) {
  93.                     param->cr_out = str_rep(param->cr_out, ans);
  94.                     ret_code = 1;
  95.                 }
  96.                 break;
  97.             default:
  98.                 beep();
  99.         }
  100.         mvwaddch(t_win, 20, 12, (chtype) ' ');
  101.         clear_line(t_win, 21, 0, FALSE);
  102.         clear_line(t_win, 22, 0, FALSE);
  103.         wmove(t_win, 20, 12);
  104.         wrefresh(t_win);
  105.     }
  106.     delwin(t_win);
  107.     return(ret_code);
  108. }
  109.